import { Component, OnInit, Inject } from '@angular/core';

@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {
	username: string;
	password: string;
  constructor(@Inject('login') private service) { }

  ngOnInit() {
  }

  onSubmit(formValue) {
  	console.log('form', formValue)
  	const data = this.service.toLogin(formValue.login.username, formValue.login.password);
  	if (data) { 
  		alert('登陆成功!!!');
  	} else {
  		alert('用户名或密码错误!!!');
  	}
  }

  onClick() {
  	console.log('username', this.username);
  	console.log('password', this.password);
  	const data = this.service.toLogin(this.username, this.password);
  	if (data) { 
  		alert('登陆成功!!!');
  	} else {
  		alert('用户名或密码错误!!!');
  	}
  }
}
